//package server;
//
//import contacts.Contact;
//import contacts.ContactHelper;
//import org.apache.http.HttpRequest;
//import org.apache.http.RequestLine;
//import org.apache.http.params.HttpParams;
//import org.junit.Test;
//
//import java.util.HashMap;
//
//import static junit.framework.Assert.assertEquals;
//import static org.junit.Assert.assertTrue;
//import static org.mockito.Mockito.mock;
//import static org.mockito.Mockito.when;
//
///**
// * User: Jaan
// * Date: 4.12.11
// * Time: 0:28
// */
//public class HttpRequestHandlerTest {
//  HttpRequest request;
//  HttpRequestHandler requestHandler;
//  ContactHelper contactHelper;
//
//  @Test
//  public void testProcessFindNameRequest() throws Exception {
//    requestHandler = new HttpRequestHandler();
//    request = mock(HttpRequest.class);
//    contactHelper = mock(ContactHelper.class);
//    HttpParams httpParams = mock(HttpParams.class);
//    RequestLine requestLine = mock(RequestLine.class);
//    String responseURI = "http://";
//
//
//    requestHandler.contactHelper = contactHelper;
//    when(request.getParams()).thenReturn(httpParams);
//    when(request.getRequestLine()).thenReturn(requestLine);
//    when(contactHelper.getContact("Jaan")).thenReturn(new Contact("Jaan", "66.66.66.99:8945"));
//    when(requestLine.getUri()).thenReturn("/chat/findname?name=Jaan&myip=110:10:10:200:6666&ttl=3");
//    when(httpParams.getParameter("name")).thenReturn("Jaan");
//    when(httpParams.getParameter("myip")).thenReturn("110.10.10.200:6666");
//    when(httpParams.getParameter("ttl")).thenReturn(null);
//
////        assertNull(requestHandler.processFindNameRequest(request));
//
//    when(httpParams.getParameter("ttl")).thenReturn("0");
////        assertNull(requestHandler.processFindNameRequest(request));
//
//    when(httpParams.getParameter("ttl")).thenReturn("3");
////        assertEquals("/chat/sendname?name=Jaan&ip=66.66.66.99:8945", requestHandler.processFindNameRequest(request));
//
//  }
//
//  @Test
//  public void testProcessSendMessageRequest() {
//    requestHandler = new HttpRequestHandler();
//    request = mock(HttpRequest.class);
//    HttpParams httpParams = mock(HttpParams.class);
//
//    when(request.getParams()).thenReturn(httpParams);
//    when(httpParams.getParameter("myname")).thenReturn("Jaan");
//    when(httpParams.getParameter("message")).thenReturn("Testing sent message.");
//
//    assertTrue(requestHandler.processSendMessageRequest(request).contains(": Jaan: Testing sent message."));
//  }
//
//  @Test
//  public void testComposeResponse() {
//    requestHandler = new HttpRequestHandler();
//    HashMap<String, String> parameters = new HashMap<String, String>();
//    parameters.put("someName", "Jaan");
//    parameters.put("someIp", "192.168.62.132:6234");
//    parameters.put("someOtherParameter", "4Lolz");
//    String path = "/chat/sendname";
//    String responseUri = path + "?someName=Jaan&someIp=192.168.62.132:6234&someOtherParameter=4Lolz";
//
//    assertEquals(responseUri, requestHandler.composeResponse(path, parameters));
//  }
//}
